package com.endurance.mapper;

import com.endurance.pojo.Product;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import java.sql.ResultSet;
import java.sql.SQLException;

@Repository
public class ProductMapper implements RowMapper<Product> {


    @Override
    public Product mapRow(ResultSet resultSet, int i) throws SQLException {
        Product product = new Product();
        product.setPid(resultSet.getInt("pid"));
        product.setPname(resultSet.getString("pname"));
        product.setPrice(resultSet.getDouble("price"));
        product.setCategory(resultSet.getString("category"));
        return product;
    }


}
